package digui.search;

import java.util.Vector;

/**
 * @author cyt
 * @create 2020-05-29 22:23
 */
public class B {

    static int N = 6;
    static Vector<Integer> vector = new Vector<>();


    static boolean[] isUsed = new boolean[100];

    /**
     * 1 - n 之间的
     * 素数环
     *
     * @param args
     */
    public static void main(String[] args) {
        System.out.println(8 & 1);

        vector.add(1);
        dfs(1);
    }

    static void dfs(int n) {
        // 打印结果
        if (n >= N) {
            int temp = vector.firstElement() + vector.lastElement();
            if (isPri(temp) == false) {
                return;
            }
            for (Integer integer : vector) {
                System.out.print(integer);
            }
            System.out.println();
        }

        for (int i = 2; i <= N; i++) {

            if (isUsed[i]) {
                continue;
            }
            int temp = vector.get(n - 1) + i;
            // 剪枝
            if (isPri(temp) == false) {
                continue;
            }

            vector.add(i);
            isUsed[i] = true;

            dfs(n + 1);

            isUsed[i] = false;

            Integer lastElement = vector.lastElement();
            vector.remove(lastElement);
        }

    }

    static boolean isPri(int n) {
        int ans = n & 1;
        if (ans == 0) {
            return false;
        } else {
            return true;
        }
    }


}
